#ifndef CALCULATORDEC_H
#define CALCULATORDEC_H

#include <QString>
#include <QStack>
#include <QQueue>
#include "ICalculator.h"

class CalculatorDec : public ICalculator
{
protected:
    QString m_result;

    bool isDigitOrDot(QChar c);
    bool isOperator(QString c);
    bool isSymbol(QChar c);
    bool isSign(QChar c);
    bool isNumber(QString s);
    bool isLeft(QString s);
    bool isRight(QString s);
    int priority(QString s);
    bool match(QQueue<QString> exp);

    QQueue<QString> split(const QString exp); // split the expression and get the operator and operand
    bool transform(QQueue<QString> exp, QQueue<QString> &output); // transform to postfix expression
    QString calculate(QString l,QString op,QString r);
    QString calculate(QQueue<QString>& exp);

public:
    CalculatorDec();

    // implement interface
    bool expression(const QString exp) override;
    QString result() override;

};

#endif // CALCULATORDEC_H
